<%@page import="com.davinci.freemarket.dataModelLayer.model.PublicationModel"%>
<%@page import="com.davinci.freemarket.businessLayer.controllers.PublicationsController"%>
<%@page import="com.davinci.freemarket.businessLayer.controllers.CategoriasController" import= "java.util.ArrayList"%>
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" import= "com.davinci.freemarket.dataModelLayer.model.CategoriasModel" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<!-- Avoid script blocking -->
	<script></script>
	<title>Free Market - Sitio gratuito de comercio electrónico</title>
	<!-- Chico-UI Core Style Sheet -->
		<link rel="stylesheet" href="./src/ml/css/chico-min-0.9.1.css"/>
		<link rel="stylesheet" href="./src/ml/css/chico-mesh.css"/> 
</head>
<body>
<div class="ch-g1">
    <div class="box">
    	<img src="./Ecommerce-logo.png" alt="Free Market" />
        <form method="get" action="servlet/BrowserServlet" id="browser">
			<div class="autoComplete" id="a">
				<input type="text" id="autocomplete" name="search" placeholder="¿Qué estás buscando?" />
			</div>
			<div id="b">
				<input type="submit" class="ch-btn ch-secondary" value="Buscar"/>
			</div>
	 	</form>
		<a href="RegisterPage.jsp" id="register" class="YOUR_SELECTOR_Modal">Registrarse </a>|
        <a href="login.jsp" id="login" class="YOUR_SELECTOR_Modal"> Ingresar</a>
        <form method="get" action="servlet/PublisherServlet" id="publish">
        	<p><input type="submit" class="ch-btn ch-secondary" value="Publicar"/></p>
        </form>
    </div>
</div>
<div class="ch-g1">
    <div class="ch-g1-4">
        <div class="box leftcolumn">
            <h2>Categorías</h2>
            <%
            	CategoriasController categoController = new CategoriasController();
            ArrayList<CategoriasModel> categories = categoController.listCategorias(); 
            for(CategoriasModel category : categories){%>
            	<p><a href="servlet/GetPublicationServlet?publish_identifier=<%out.println(category.getName());%>"><%out.println(category.getName()); %></a></p>
            <%}%>
            
            
        </div>
    </div>
    <div class="ch-g3-4">
        <div class="box rightcolumn">
        <h2>Más vendidos</h2>
        	<div class="masVend ch-carousel">
        		<ul>
		            <%
		            	PublicationsController mv = new PublicationsController();
		            ArrayList<PublicationModel> masVendidos = mv.getMasVendidos();
		            for(PublicationModel publication:masVendidos){
		            	%><li><img src="http://localhost:8080/J2EE_DAVINCI_PROJECT/publications/<%out.println(publication.getPublicationId());%>.jpg" height="90px" weight="90px"><p align="center"><%out.println(publication.getTitle());%></p><p align="center" class="price">$ <%out.println(publication.getPrice());%></p></li><%
		            }
		            %>	           
           		 </ul>
           	</div>
           	<br>
         <h2>Recién llegados</h2>
         	<div class="recLle ch-carousel">
         		<ul>
             <%
	            	PublicationsController rc = new PublicationsController();
	            ArrayList<PublicationModel> recienLlegados = rc.getRecienLlegados();
	            for(PublicationModel publication:recienLlegados){
	            	%><li><img src="http://localhost:8080/J2EE_DAVINCI_PROJECT/publications/<%out.println(publication.getPublicationId());%>.jpg" height="90px" weight="90px"><p align="center"><%out.println(publication.getTitle());%></p><p align="center" class="price">$ <%out.println(publication.getPrice());%></p></li><%
	            }
            %>
            	</ul>
            </div>

        </div>
    </div>
</div>
<div class="ch-g1">
    <div class="box">         
  <p align="center">El uso de este sitio web implica la aceptación de los Términos y   Condiciones</a> y de las Políticas de   Privacidad</a> de Free Market S.A</p>
  <p align="center"	>Copyright © 2010-2011 Free Market S.A.</p>
    </div>
</div>



		
		<script src="http://code.jquery.com/jquery-1.7.js"></script>
		<script src="src/js/chico-0.9.1.js?debug=true"></script>	
		<script src="./src/plugins/gallery/chico.gallery.js"></script>
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.x.x/jquery.min.js"></script>

		<script> 
		var foo = $(".masVend").carousel();
		var foo = $(".recLle").carousel();
		
		// Automatic version
        var title = document.title + ' ' + ch.version;
        document.title = title; // Use old school because IE6 dosen't work fine with DOM API.
        document.getElementsByTagName("h1")[0].innerHTML = title;

		// Components
		
		// AutoComplete
		var ac = $(".autoComplete").autoComplete({url:"http://chico.com:8080/suggest/"});
		
		var autoComplete = function(data){
			ac.suggest(data);
		}
		
		// Blink
		$("#doHighlight").bind("mousedown",function(){$("#example").blink();});
		
		// Accordion
		var ch_acco = $(".YOUR_SELECTOR_Accordion").accordion({
			selected: "1#2"
		});
		
		// Menu
		var ch_menu = $(".YOUR_SELECTOR_Menu").menu();
		
		// Dropdown
		var ch_drop = $(".YOUR_SELECTOR_Dropdown").dropdown();
		var ch_drop = $(".myDropdown").dropdown();

		// Carousel
		var ch_caro = $(".YOUR_SELECTOR_Carousel").carousel({
			pagination:true
		});
					
		// Modal
		var ch_moda = $(".YOUR_SELECTOR_Modal").modal({
			width: "500px",
			height: "300px"
		});
		
		// Modal with invisible DOM Content		
		var ch_moda_invisible = $(".YOUR_SELECTOR_Modal_invisible").modal({ 
		  content:"#invisible-content"
		});
		
		// Transition
		var ch_tran = $(".YOUR_SELECTOR_Transition").transition();
		
		// Layer on click
		var ch_layeC = $(".YOUR_SELECTOR_LayerCloseButton").layer({
			event: "click",
			closeHandler: "button",
			content: "#invisible-content-for-layer"
		});
		
		// Layer on click
		var ch_laye = $(".YOUR_SELECTOR_LayerOnclick").layer({
			event: "click",
			content: "#invisible-content"
		});
		
		// Layer on mouseover
		var ch_layr = $(".YOUR_SELECTOR_LayerOnmouseover").layer("<p>foo</p>");

		// Tooltip
		var ch_tool = $(".YOUR_SELECTOR_Tooltip").tooltip();

		// Tab Navigator
		var ch_tabs = $(".YOUR_SELECTOR_TabNavigator").tabNavigator();

		// Expando
		var ch_expa = $(".YOUR_SELECTOR_Expando").expando();

		// Calendar
		var calendar = $(".myCalendar").calendar({
			selected: "2011/11/15",
			from: "2010/11/05",
			to: "2012/11/25"
		});

		var ch_ico = $(".ch-form-ico").layer({content:"Help",event:"click", offset:"-12 15"});
			
		// Form
		var ch_form = $('.form').form();

		// Watchers
		var ch_wprice = $("#price").price("Price please!").and().required("algo");
		var ch_wch1 = $("#email").required("requerid").and().email("Guachin emial").and().minLength(10);
		var ch_wch11 = $("#custom").custom(function(v){ return (v.toString().indexOf("1")>-1) ? true : false ;},"Mensjae largo para probar mensaje de varias lineas y ajustar el padding interno de la caja.")
												.and()
												.required()
												.and()
												.custom(function(v){ 
													count++;
													console.log("Custom " + count )
													return (v.toString().indexOf("2")>-1) ? true : false ;
												},"2");
		var ch_wch3 = $("#number").number().and().min(20);
		var ch_wch4 = $("#range").min(1).and().max(10);
		var ch_wch5 = $("#characters").maxLength(20).and().minLength(6);
		var ch_wch6 = $("#required_disabled, #select2, #select3, .check2, .check3, .radio2, .radio3, .radio4, #textarea2, #textarea3").required("Required");


		// Gallery
		var ch_gal = $(".ch-gallery").gallery();

	</script>

</body>
</html>